package com.dream.model.app;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.dream.model.base.AppUserModelBase;

@Entity
@Table(name="t_app_code_item")
public class AppCodeItem extends AppUserModelBase implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 849501148393868921L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	@Column(name="app_code_id")
	private Long appCodeId;
	
	@Column(name="seq")
	private Integer sequence;
	
	@Column(name="name")
	private String name;

	@Column(name="name_en")
	private String nameEn;
	
	@Column(name="deleted")
	@Type(type = "org.hibernate.type.NumericBooleanType")
	private boolean deleted;
	
	@Column(name="extension")
	private String extension;

	@Column(name="extension_a")
	private String extensionA;
	
	@Column(name="extension_b")
	private String extensionB;

	@Column(name="extension_c")
	private String extensionC;
	
	@ManyToOne(targetEntity=AppCode.class,fetch=FetchType.EAGER)
	@JoinColumn(name="app_code_id",updatable = false, insertable = false)
	private AppCode appCode;
	
	public AppCode getAppCode() {
		return appCode;
	}

	public void setAppCode(AppCode appCode) {
		this.appCode = appCode;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getAppCodeId() {
		return appCodeId;
	}

	public void setAppCodeId(Long appCodeId) {
		this.appCodeId = appCodeId;
	}

	public Integer getSequence() {
		return sequence;
	}

	public void setSequence(Integer sequence) {
		this.sequence = sequence;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNameEn() {
		return nameEn;
	}

	public void setNameEn(String nameEn) {
		this.nameEn = nameEn;
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	public String getExtension() {
		return extension;
	}

	public void setExtension(String extension) {
		this.extension = extension;
	}

	public String getExtensionA() {
		return extensionA;
	}

	public void setExtensionA(String extensionA) {
		this.extensionA = extensionA;
	}

	public String getExtensionB() {
		return extensionB;
	}

	public void setExtensionB(String extensionB) {
		this.extensionB = extensionB;
	}

	public String getExtensionC() {
		return extensionC;
	}

	public void setExtensionC(String extensionC) {
		this.extensionC = extensionC;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AppCodeItem other = (AppCodeItem) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
}
